package com.starhub.application.rag.constant;

import io.milvus.param.IndexType;
import io.milvus.param.MetricType;

/**
 * rag常量
 * @version: V1.0
 * @author: liuhf
 * @time 2025-06-05
 */
public class RagConstant {

    // 默认Milvus 配置标识
    public static String MILVUS_MARK = "starhub";

    // 默认Milvus 向量维度
    public static int MILVUS_DIMENSION = 1024;

    // 默认Milvus 索引类型  图结构索引
    public static IndexType MILVUS_INDEX_TYPE = IndexType.HNSW;
    
    // 默认Milvus 索引参数  余弦相似度
    public static MetricType MILVUS_METRIC_TYPE = MetricType.COSINE;

    // 默认Milvus 索引参数  图结构索引
    public static String MILVUS_EXTRA_PARAM = "{\"M\":8,\"efConstruction\":64}";

    // 数据向量化MetaData字段
    public static class EmbeddingMetaData {
        public static final String INDEX = "index";
        public static final String TEXT_ID = "text_id";
        public static final String ITEM_ID = "item_id";
        public static final String COLLECTION_ID = "collection_id";
        public static final String BASE_ID = "base_id";
        public static final String SEGMENT_ID = "segment_id";
    }

    // 关联向量化MetaData字段
    public static class LinkMetaData {
        public static final String MAIN_ID = "main_id";
        public static final String MAIN_COLLECTION = "main_collection";
        public static final String META_COLLECTION = "meta_collection";
        public static final String BASE_ID = "base_id";
    }

    // langchain4j milvus数据结构
    public static class LangchainMilvusFields {
        public static final String FIELD_ID = "id";
        public static final String FIELD_TEXT = "text";
        public static final String FIELD_VECTOR = "vector";   
        public static final String FIELD_METADATA = "metadata";
    }
    
    // 文档分割器数据
    public static class DocumentSplitterData {
        public static final int MAX_PARAGRAPH_SIZE = 200;
        public static final int MAX_OVERLAP_SIZE = 50;
    }

    // 主数据关联表默认后缀
    public static final String META_POSTFIX = "_meta";

    // 元数据关联字段默认前缀
    public static final String META_PREFIX = "mdl_";

    /**
     * 向量化检索召回数量
     */
    public static final Integer RETRIEVE_EMBEDDING_COUNT = 10;

    /**
     * 向量化检索召回最小相似度
     */
    public static final Double RETRIEVE_EMBEDDING_MIN_SCORE = 0.7;
}
